<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 25.  Building Berkeley DB for the BREW simulator</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
    <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
    <link rel="prev" href="debug_printlog.html" title="Reviewing Berkeley DB log files" />
    <link rel="next" href="ch25s02.html" title="Building a BREW applet for the physical device" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 25. 
		Building Berkeley DB for the BREW simulator
        </th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="debug_printlog.html">Prev</a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="ch25s02.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="build_brew"></a>Chapter 25. 
		Building Berkeley DB for the BREW simulator
        </h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <dl>
          <dt>
            <span class="sect1">
              <a href="build_brew.html#id1628111">Building a BREW applet with Berkeley DB library</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="ch25s02.html">Building a BREW applet for the physical device</a>
            </span>
          </dt>
        </dl>
      </div>
      <p>This chapter has general instructions for building the Berkeley DB library
and applets for the BREW platform.</p>
      <p>The <code class="filename">build_brew</code> directory in the Berkeley DB distribution contains
project files for Microsoft Visual C++:</p>
      <div class="informaltable">
        <table border="1" width="80%">
          <colgroup>
            <col />
            <col />
          </colgroup>
          <thead>
            <tr>
              <th>Project File</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td align="left">bdb_brew.dsw</td>
              <td align="left">Visual C++ 6.0 workspace</td>
            </tr>
            <tr>
              <td align="left">bdb_brew.dsp</td>
              <td align="left">Visual C++ 6.0 project</td>
            </tr>
          </tbody>
        </table>
      </div>
      <p>The project file can be used to build the Berkeley DB library for the BREW
platform. Both BREW SDK versions 2 and 3 are supported.  By default, the
build is for BREW SDK version 2.</p>
      <p>The steps for building the Berkeley DB library for the BREW Simulator are as
follows:</p>
      <div class="orderedlist">
        <ol type="1">
          <li>Install the BREW SDK and BREW SDK Tools.</li>
          <li>To build for BREW SDK version 3, edit the Berkeley DB source distribution file
<code class="filename">build_brew/db_config.h</code> file and <span class="bold"><strong>remove</strong></span> the line
"#define HAVE_BREW_SDK2".  No changes are required to build for BREW SDK
version 2.</li>
          <li>Select <span class="emphasis"><em>File -&gt; Open Workspace</em></span>.  Look in the build_brew
directory for Workspaces, select <span class="emphasis"><em>bdb_brew.dsw</em></span>, and select
<span class="emphasis"><em>Open</em></span>.</li>
          <li>The BREW SDK creates an environment entry "BREWDIR" after the SDK
installation. Confirm the entry exists, and if not, create an
environment entry which points to the BREW SDK's root directory.</li>
          <li>For the BREW platform, only the project "bdb_brew" is available.  Set
the bdb_brew project as the active project and select the appropriate
option for the build_all project (Debug or Release). Then select
<span class="emphasis"><em>OK</em></span>.</li>
          <li>To build, press F7.</li>
        </ol>
      </div>
      <p>The build results are placed in a subdirectory of build_brew named after
the selected configuration (for example, <code class="filename">build_brew\Release</code> or
<code class="filename">build_brew\Debug</code>).</p>
      <p>When building the application during development, you should normally
use compile options "Debug Multithreaded DLL" and link against
<code class="filename">build_brew\Debug\bdb_brew.lib</code>. You can also build using a
release version of the Berkeley DB libraries and tools, which will be placed
in <code class="filename">build_brew\Release\bdb_brew.lib</code>. When linking against the
release build, you should compile your code with the "Release
Multithreaded DLL" compile option. You will also need to add the
<code class="filename">build_brew</code> directory to the list of include directories of your
application's project, or copy the Berkeley DB include files to another
location.</p>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="id1628111"></a>Building a BREW applet with Berkeley DB library</h2>
            </div>
          </div>
        </div>
        <p>Building a Berkeley DB application in the BREW environment is similar to
building in a Windows environment.  Ensure that <code class="filename">db.h</code> is in the
build include path and <code class="filename">bdb_brew.lib</code> is in the build library
path (alternatively, you can add project dependencies to the
<code class="filename">bdb_brew</code> project).</p>
        <p>BREW applets require a few minor additions:</p>
        <div class="orderedlist">
          <ol type="1">
            <li>The <span class="bold"><strong>BDBApp</strong></span> structure must be extended -- the extended
definition of BDBApp is found in the include file <code class="filename">db.h</code>.</li>
            <li>Before any Berkeley DB operations are performed, the applet must call the "int
brew_bdb_begin(void)" function.  This function returns 0 on success, and
non-zero on failure.</li>
            <li>After the last Berkeley DB operation is performed, the applet must call the
"void brew_bdb_end(void)" function.  Note that the brew_bdb_end function
cannot be called in the applet "cleanup" function.  If that is a
requirement, use the following code instead:
<pre class="programlisting">BDBApp *pMe=(BDBApp *)po;
if (pMe-&gt;db_global_values != NULL)
	FREE(pMe-&gt;db_global_values);</pre></li>
          </ol>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="debug_printlog.html">Prev</a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="ch25s02.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Reviewing Berkeley DB log files </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Building a BREW applet for the physical device</td>
        </tr>
      </table>
    </div>
  </body>
</html>
